//
//  VC_ClassicSentence.m
//  yjw-winner
//
//  Created by 隆霁 on 2018/9/26.
//  Copyright © 2018年 Shanghai decade financial information service co., LTD. All rights reserved.
//

#import "VC_ClassicSentence.h"
#import "Cell_ClassicSentence.h"
#import "Model_ClassicSentence.h"

static NSString *identifier = @"classic_sentence_cell_identifier";
@interface VC_ClassicSentence ()<UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@property (nonatomic, strong) NSArray *dataArray;

@property (nonatomic, strong) id shareData;
@end

@implementation VC_ClassicSentence


- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setBarStyle:UIBarStyleBlackOpaque];
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setBarStyle:UIBarStyleDefault];
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
}

- (NSArray *)dataArray {
    if (!_dataArray) {
        NSMutableArray *mArr = [NSMutableArray arrayWithCapacity:10];
        for (int i = 0; i < 10; i++) {
            Model_ClassicSentence *model = [[Model_ClassicSentence alloc] init];
            if (i % 2 == 0) {
                model.context = @"一个好的社区，能够不断生产优质内容吗？从而带来持续、稳定的高质量流量。在今天这个流量很贵的时代，这就是一个非常大的价值。";
            }else {
                model.context = @"用户分享行为是什么？往自己身上贴标签——我分享什么，我就是什么。";
            }
            [mArr addObject:model];
        }
        _dataArray = [NSArray arrayWithArray:mArr];
    }
    return _dataArray;
}
- (instancetype)init {
    if (self = [super init]) {
        self = [[UIStoryboard storyboardWithName:@"CourseListStoryBoard" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:NSStringFromClass([self class])];
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([Cell_ClassicSentence class]) bundle:[NSBundle mainBundle]] forCellReuseIdentifier:identifier];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



#pragma mark --mark UITableViewDelegete UITableViewDataSource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    Cell_ClassicSentence *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
    Model_ClassicSentence *model = self.dataArray[indexPath.row];
    if (!cell) {
        cell = [[Cell_ClassicSentence alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
    cell.selectedBackgroundView.backgroundColor = MJRefreshColor(56, 56, 56);
    cell.contextLabel.text = model.context;
    return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    Model_ClassicSentence *model = self.dataArray[indexPath.row];
    return model.cellHeight;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    self.shareData = indexPath;
}

#pragma mark --mark EVENT

/**
 生成图片

 @param sender sender
 */
- (IBAction)makeupPictureButtonClick:(UIButton *)sender {
    if (self.shareData) {
        [self performSegueWithIdentifier:@"identifier" sender:self];
    }else {
        // 为选择
        [MBProgressHUD showSuccess:@"请选择分享内容"];
    }
}




@end
